<template>
  <div class="content">
    <dt-search ref="search" :label-width="90">
      <Button type="primary" v-if="unlocking('0207050201')" @click='onExport'>导出</Button>
    </dt-search>
    
    <dt-grid ref="table" :page="{ rows: 20 }" :onFetch='onFetch' />
    
    <update-modal ref='update' />
    <carryto-modal ref='carryto' />
	</div>
</template>

<script>
  import Column from './opt/Column.js'
  import SearchOpt from './opt/SearchOpt.js'
  
  import updateModal from './components/update-modal.vue'
  import carrytoModal from './components/carryto-modal.vue'
  
  import financialMgr from '@/biz/report/financialReport.js'
  
  export default {
    components: {
      updateModal,
      carrytoModal
    },
    data() {
      return {
        search: {}
      }
    },
    mounted() {
      this.$refs.table.init(this, new Column())
      this.$refs.search.init(this.$refs.table, new SearchOpt())
      this.$refs.table.fetch()
    },
    methods: {
      onFetch(data) {
        this.search = data
        return financialMgr.commReportList(data)
      },
      onExport() {
        financialMgr.commReportExport({
          orgIds: this.search.orgIds || [],
          housesId: this.search.housesId || null,
          status: this.search.status || null
        })
      },
      onUpdate(item) {
        this.$refs.update.show(item, () => {
          this.$refs.table.fetch()
        })
      },
      onCarryto(item) {
        this.$refs.carryto.show(item)
      },
    },
  }
</script>

<style lang="scss" scoped>
  .content {
    padding: 20px;
  }
</style>
